//
//  NetWorkManager.swift
//  WeiBoPro
//
//  Created by nadyboy on 2018/4/26.
//  Copyright © 2018年 hjh. All rights reserved.
//
enum HTTPMethod {
    case GTE
    case POST
}
import UIKit
import AFNetworking
class NetWorkManager: NSObject {

    lazy var manager: AFHTTPSessionManager = {
        
        let manager = AFHTTPSessionManager()
        manager.responseSerializer.acceptableContentTypes?.insert("text/html")
        return manager
    }()
  
    /**
     网络请求
     
     */
    func HttpRequest(url:String,params:Any?,httpType:HTTPMethod = .GTE) {
        if httpType == .GTE {
            
            manager.get(url, parameters: params, progress: { (progress) in
                
            }, success: { (task:URLSessionDataTask?, result:Any?) in
                print("success--\(String(describing: result))")
            }) { (task:URLSessionDataTask?, error:Error) in
                print("fail--\(error)")

            }
            
        }else if httpType == .POST
        {
            manager.post(url, parameters: params, progress: nil, success: { (task:URLSessionDataTask?, result:Any?) in
                print("success--\(result)")

            }) { (task:URLSessionDataTask?, error:Error) in
                print("fail--\(error)")

            }
        }
    }
}
